package com.bwie.house.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.common.utils.PageUtils;
import com.bwie.common.utils.Query;

import com.bwie.house.dao.SchoolDao;
import com.bwie.house.entity.SchoolEntity;
import com.bwie.house.service.SchoolService;


@Service("schoolService")
public class SchoolServiceImpl extends ServiceImpl<SchoolDao, SchoolEntity> implements SchoolService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<SchoolEntity> wrapper = new QueryWrapper<>();

        String shengid = (String) params.get("shengid");
        String shiid = (String) params.get("shiid");

        if (StringUtils.isNotEmpty(shengid)){
            wrapper.eq("shen_id",shengid);
        }
        if (StringUtils.isNotEmpty(shiid)){
            wrapper.eq("shi_id",shiid);
        }

        IPage<SchoolEntity> page = this.page(
                new Query<SchoolEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

}